home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / cbm / 4518 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: saluki-news.wham.siu.edu!usenet
  2. From: <agent@siu.edu>
  3. Newsgroups: comp.sys.cbm,comp.os.misc,alt.comp.hardware.homebuilt,comp.sys.apple2,comp.sys.apple2.programmer,comp.sys.atari.8bit
  4. Subject: Re: 6502 Multitasking OS announce
  5. Date: 25 Mar 1996 04:46:09 GMT
  6. Organization: Southern Illinois University
  7. Message-ID: <4j58eh$btc@saluki-news.wham.siu.edu>
  8. References: <4i94fs$stj@narses.hrz.tu-chemnitz.de> <holger.948.00030EE6@deep.hb.provi.de> <4ijtbe$7ca@no-names.nerdc.ufl.edu> <4ijuic$iiq@gatekeeper.liffe.com> <4innc7$hc4@no-names.nerdc.ufl.edu> <4itkri$qlc@seagoon.newcastle.edu.au>
  9. NNTP-Posting-Host: mac0160.clc1.siu.edu
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: quoted-printable
  13. X-Mailer: Mozilla 1.1N (Macintosh; I; PPC)
  14. X-URL: news:4itkri$qlc@seagoon.newcastle.edu.au
  15.  
  16. How about this idea, to handle stacks?  I read a similar thing in an 
  17. issue of Dr. Dobbs Journal, in an article about a small multitasker.
  18.  
  19. Given that the stack is mostly going to be used for minor parameter 
  20. passing and jsr's.  I think is a good assumption -- other data 
  21. structures are better suited for larger jobs.
  22.  
  23. Instead of copying the stack to and fro on every task switch, how about 
  24. subdividing it?  Each task would be allocated a portion of the stack.  A 
  25. task switch moves between the portions by adding or subtracting numbers 
  26. from the stack register.
  27.  
  28. For example, let's say that we are currently on task 1.  Its stack is 
  29. partially filled.  The stack register holds 240.  Now there is a task 
  30. switch, to task 2.  The interrupt service routine stores the depth of 
  31. the stack register on task 1's stack, which in this case, is 16.  Now, 
  32. the OS has also recorded where task 2's stack pointer was the last time 
  33. it was active, in the format of 192 - n.  It loads up n, subtracts it 
  34. from 192, stores that in the stack register, giving xxx in the diagram 
  35. below (the correct stack entry), and executes an RTI.  It will return to 
  36. the appropriate point in task 2, because task 2 was halted by an 
  37. Jump-to-Interrupt (forgot opcode) to the OS, and the last thing put on 
  38. the stack was the return address to task 2's state.  So the RTI will 
  39. return to that state.
  40.  
  41. Now, how to handle allocation of the stack?  Well, some routines, 
  42. particularly those needing recursion, need a lot of stack.  Others don't 
  43. need much.  So when a task is initiated, it can request how much it 
  44. expects to need, and the OS can allocate such-and-so.
  45.  
  46. 256 -----------------
  47.  :       Task 1       <- 240: 256-16
  48.  :  
  49. 192 -----------------
  50.  :       Task 2       <- xxx: 192-n=03   
  51.  :
  52. 144 -----------------
  53.  :    Task 3 (small)
  54. 112 -----------------
  55.  :    Task 4 (wants
  56.  :            lots)
  57.  :
  58.  48 -----------------
  59.  :       System
  60.  :      or Free
  61.  =050  -----------------
  62.  
  63. What do you think?  Is it workable?  (Again, due credits to Dr. Dobbs' 
  64. article by whoever wrote it.)
  65.  
  66.  
  67.